package com.young.commom.httpclient;

/**
 * @description：
 * @author: yangyahui01
 * @date: 11/29/24 12:38 PM
 */
public abstract class AbstractHttpClientTemplate implements HttpClientTemplate{
    protected static final String CONTENT_TYPE_JSON = "application/json";
    protected static final String CONTENT_TYPE_FORM = "application/x-www-form-urlencoded";
    protected static final String CONTENT_TYPE_JSON_PATTERN = "application/json; charset={0}";
    protected static final String CONTENT_TYPE_FORM_PATTERN = "application/x-www-form-urlencoded; charset={0}";
    protected HttpClientConfiguration configuration = HttpClientConfiguration.common();
    protected String charset;
    private volatile boolean init;

    public AbstractHttpClientTemplate() {
        this.charset = this.configuration.getCharset();
        this.init = false;
    }

    public AbstractHttpClientTemplate(HttpClientConfiguration configuration) {
        this.charset = this.configuration.getCharset();
        this.init = false;
        if (configuration != null) {
            this.configuration = configuration;
        }

    }

    public synchronized void init() {
        if (!this.init) {
            this.init = true;
        }
    }

    protected HttpClientConfiguration getConfiguration() {
        return this.configuration;
    }
}
